Skip to content

[SelectionDAG] Remove PeekThroughFreeze (NFC) #148022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

AZero13
Copy link
Contributor

@AZero13 AZero13 commented Jul 10, 2025

Now that SelectionDAG already peeks through freezes, this is not needed anymore.

Now that SelectionDAG already peeks through freezes, this is not needed anymore.
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Jul 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: AZero13 (AZero13)

Changes

Now that SelectionDAG already peeks through freezes, this is not needed anymore.


Full diff: https://github.com/llvm/llvm-project/pull/148022.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+1-7)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 9ffdda28f7899..6767606f0719a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4067,18 +4067,12 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
   unsigned BitWidth = VT.getScalarSizeInBits();
   SDLoc DL(N);
 
-  auto PeekThroughFreeze = [](SDValue N) {
-    if (N->getOpcode() == ISD::FREEZE && N.hasOneUse())
-      return N->getOperand(0);
-    return N;
-  };
-
   if (SDValue V = foldSubCtlzNot<EmptyMatchContext>(N, DAG))
     return V;
 
   // fold (sub x, x) -> 0
   // FIXME: Refactor this and xor and other similar operations together.
-  if (PeekThroughFreeze(N0) == PeekThroughFreeze(N1))
+  if (N0 == N1)
     return tryFoldToZero(DL, TLI, VT, DAG, LegalOperations);
 
   // fold (sub c1, c2) -> c3

@topperc
Copy link
Collaborator

topperc commented Jul 10, 2025

Here are two tests where I believe this code triggers https://godbolt.org/z/sY79E6d5o https://godbolt.org/z/raosvoWsT

@topperc topperc requested review from nikic and RKSimon July 10, 2025 23:05
@AZero13
Copy link
Contributor Author

AZero13 commented Jul 11, 2025

Here are two tests where I believe this code triggers https://godbolt.org/z/sY79E6d5o https://godbolt.org/z/raosvoWsT

you know i swapped sub with xor and suddenly the div made it

@AZero13
Copy link
Contributor Author

AZero13 commented Jul 11, 2025

Disregard this. Let's go back to #147821

@AZero13 AZero13 closed this Jul 11, 2025
@AZero13 AZero13 deleted the patch-3 branch July 11, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants